local tulin = fk.CreateSkill {
    name = "kq__tulin",
}

local DIY = require "packages/diy_utility/diy_utility"

tulin:addAcquireEffect(function (self, player, is_start)
  player.room:addSkill("#CenterArea")
end)

tulin:addEffect("viewas", {
  pattern = ".",
  prompt = "#kq__tulin",
  expand_pile = function(self, player)
    return Fk:currentRoom():getBanner("@$CenterArea")
  end,
  card_filter = function(self, player, to_select, selected)
    local card = Fk:getCardById(to_select)
    if #selected == 0 
      and #table.filter(Fk:currentRoom():getBanner("@$CenterArea"), function(id)
            return id == to_select
      end) ~=0  and
      not table.contains(player:getTableMark("kq__tulin_used-turn"), Fk:getCardById(to_select).name) then
      if Fk.currentResponsePattern == nil then
        return player:canUse(card) and not player:prohibitUse(card)
      else
        return Exppattern:Parse(Fk.currentResponsePattern):match(card)
      end
    end
  end,
  view_as = function(self, player, cards)
    if #cards ~= 1 then return end
    return Fk:getCardById(cards[1])
  end,
  before_use = function (self, player, use)
    player.room:addTableMark(player, "kq__tulin_used-turn", use.card.name)
  end,
 after_use=function (self, player, use)
    if not use.damageDealt then
        player.room:damage{
           from = player,
           to = player,
           damage = 1,
           skillName = tulin.name,
           damageType = fk.IceDamage
          }
    end
 end,
  enabled_at_play = function(self, player)
    return #table.filter(Fk:currentRoom():getBanner("@$CenterArea"), function(id)
        return id
    end) ~= 0
  end,
  enabled_at_response = function(self, player, response)
    return #table.filter(Fk:currentRoom():getBanner("@$CenterArea"), function(id)
        return id
    end) ~= 0
  end,
})


Fk:loadTranslationTable {
    ["kq__tulin"] = "徒凜",
    [":kq__tulin"] = "每回合每种牌名限一次，你可以使用或打出一张中央区的牌，然后若此牌未造成伤害，你对自己造成1点冰冻伤害。",
    ["#kq__tulin"] = "使用或打出一张中央区的牌",
}

return tulin